package com.neusoft.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.po.CalendarPO;
import com.neusoft.service.CalendarService;


@CrossOrigin
@RestController
public class CalendarHandler {

	@Autowired
	private CalendarService ser;
	
	@GetMapping("/getCalendar")
	public List<CalendarPO> getCalendar(Integer year) {
		List<CalendarPO> res = ser.getCalendar(year);
		if(res.isEmpty() || res == null) {
			res = ser.getCalendar(year);
		}
		return res;
	}

	@PostMapping("/updateCalendar")
	public Integer updateCalendar(@RequestBody CalendarPO po) {
		return ser.updateCalendar(po);
	}
}
